﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace CSharp4ExpressionMetaCompiler
{
    public static class ExpressionHelper
    {
        public static Expression<TDelegate> Translate<TDelegate>(Expression<TDelegate> expression)
        {
            var visitor = new BlockCompilerVisitor();
            return visitor.StartVisit(expression) as Expression<TDelegate>;
        }
        public static Expression Translate(Expression expression)
        {
            var visitor = new BlockCompilerVisitor();
            return visitor.StartVisit(expression);
        }
    }

    public class Block
    {
        //prevents the use of the default public constructor
        //so we hare sure that the only way to get Block instances is to use Block.Start()
        private Block()
        {
        }

        public static Block Declare<T>(T locals, Action<T> block)
        {
            throw new NotImplementedException();
        }

        public static Block Start<T>(T locals, Action<T> block)
        {
            throw new NotImplementedException();
        }

        public static R Start<T, R>(T locals, Func<T, R> block)
        {
            throw new NotImplementedException();
        }

        public static Block Default { get; private set; }

        public Block _(Action action)
        {
            throw new NotImplementedException();
        }

        public Block Assign<T>(T leftExpression, T rightExpression)
        {
            throw new NotImplementedException();
        }


        public Block Loop(Action block)
        {
            throw new NotImplementedException();
        }

        public Block IfThen(bool testExpression, Action thenBlock)
        {
            throw new NotImplementedException();
        }

        public Block IfThenElse(bool testExpression, Action thenBlock, Action elseBlock)
        {
            throw new NotImplementedException();
        }

        public Block While(bool testExpression, Action block)
        {
            throw new NotImplementedException();
        }

        public Block For(int from, Predicate<int> condition, Action<int> block)
        {
            throw new NotImplementedException();
        }

        public Block Label(string name)
        {
            throw new NotImplementedException();
        }

        public Block Goto(string name)
        {
            throw new NotImplementedException();
        }
    }
}
